from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, BigInteger, JSON, DateTime
from educate_ai.database import Base

class PaperORM(Base):
    """试卷表ORM模型（与数据库表直接映射）"""
    __tablename__ = "papers"

    id = Column(BigInteger, primary_key=True, autoincrement=True, comment="主键：自增编号")
    title = Column(String(255), nullable=False, comment="试卷名称")
    choice_count = Column(Integer, default=0, comment="选择题数量")
    fill_count = Column(Integer, default=0, comment="填空题数量")
    short_count = Column(Integer, default=0, comment="简答题数量")
    difficulty_range = Column(Integer, default=5, comment="难度范围（1-10）")
    major = Column(String(100), nullable=False, comment="所属专业")
    course = Column(String(100), nullable=False, comment="课程名称")
    subject_requirements = Column(Text, nullable=True, comment="考查主题")
    question_ids = Column(JSON, nullable=False, comment="包含的题目ID（JSON格式）")
    total_score = Column(Integer, default=100, comment="试卷总分")
    time_limit = Column(Integer, default=120, comment="考试时长（分钟）")
    created_at = Column(DateTime, default=datetime.now, comment="创建时间")

